package com.exsun.ex1077.ui.activity.privacy

import android.os.Bundle
import com.drake.brv.utils.divider
import com.drake.brv.utils.linear
import com.drake.brv.utils.setup
import com.exsun.ex1077.R
import com.exsun.ex1077.databinding.ActivityPrivacyBinding
import com.exsun.ex1077.network.ApiUrl
import com.exsun.ex1077.ui.activity.web.WebActivity
import com.zhangping.fastjetpack.base.BaseActivity
import com.zhangping.fastjetpack.base.BaseViewModel
import com.zhangping.fastjetpack.extend.toActivity
import com.zhangping.fastjetpack.extend.toColorRes
import kotlinx.android.synthetic.main.activity_privacy.*

/**
 * 描述：隐私政策
 * 作者：ZhangPing
 * 创建时间：2022/11/4 14:00
 */
class PrivacyActivity: BaseActivity<BaseViewModel, ActivityPrivacyBinding>() {

    override fun title() = "隐私政策"

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.vm = mViewModel
        super.initView(savedInstanceState)
        listView.linear().divider {
            setDivider(1, true)
            setColor(R.color.divider.toColorRes())
        }.setup {
            addType<String>(R.layout.list_item_privacy)
            onClick(R.id.itemRoot){
                val name = getModel<String>()
                toActivity<WebActivity>(Bundle().apply {
                    putString("title", name)
                    putString("url", if (name == "用户协议") ApiUrl.USER_AGREEMENT else ApiUrl.PRIVACY_AGREEMENT)
                })
            }
        }.models = arrayListOf("用户协议", "隐私政策")
    }

}